2D Camera Bounding with offset

Hi all, this is my first time posting on the forums, hope i don’t offend anyone with my noobish question…
anyway, back to the question., i have done up a camera bound script which prevents the camera from viewing the blue background in my game, the camera is attached to my player as a child. i wanted to ask if there was a way to add back the offset moved by the player when he reaches the border cos the moment i move in a different direction the camera just moves with the player being in his last position

CameraMovement class

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class CameraMovement : MonoBehaviour {
	public GameObject Player;
	Vector3 minCamera;
	Vector3 MaxCamera;
	Camera mainCam;
	public int MinY,MaxY,MinX,MaxX;
	// Use this for initialization
	void Start () 
	{
//		MinY = 0;
//		MaxY = 0;
//		MinX = 0;
//		MaxX = 0;
		mainCam = Camera.mainCamera;
	}
	void  CameraRestriction ()
	{
        if(mainCam.transform.position.y < MinY)//-1310
        {
            mainCam.transform.position = new Vector3(mainCam.transform.position.x,MinY,mainCam.transform.position.z);
        }
        if(mainCam.transform.position.y > MaxY)//288
        {
            mainCam.transform.position = new Vector3(mainCam.transform.position.x,MaxY,mainCam.transform.position.z);
        }
       
        if(mainCam.transform.position.x < MinX)//-1129
        {
            mainCam.transform.position = new Vector3(MinX,mainCam.transform.position.y,mainCam.transform.position.z);
        }
        if(mainCam.transform.position.x > MaxX)//130
        {
            mainCam.transform.position =  new Vector3(MaxX,mainCam.transform.position.y,mainCam.transform.position.z);
        }
		//transform.LookAt( GameObject.FindGameObjectWithTag("Player").transform);
    }
	
	void OnDrawGizmos()
	{
//		Gizmos.DrawWireCube(new Vector(Mathf.,MaxY-MinY),Vector3(10,10,10));
	}
	
	void CameraOffset()
		{
			Vector3 Offset;
			
		}
	// Update is called once per frame
	void Update () 
	{
		//Gizmos.DrawCube(Vector3.one,new Vector3(MaxX-MinX,MaxY-MinY,0));
	
			CameraRestriction ();
		
		
	}
}

Nevermind found the answer to my problem
i was suppose to check with the player’s position not camera’s position

it was this part

void  CameraRestriction ()
	{
        if(Player.position.y < MinY)//-1345
        {
            mainCam.transform.position = new Vector3(mainCam.transform.position.x,MinY,mainCam.transform.position.z);
        }
        else if(Player.position.y > MaxY)//288
        {
            mainCam.transform.position = new Vector3(mainCam.transform.position.x,MaxY,mainCam.transform.position.z);
        }
       
        if(Player.position.x < MinX)//-1228
        {
            mainCam.transform.position = new Vector3(MinX,mainCam.transform.position.y,mainCam.transform.position.z);
        }
        else if(Player.position.x > MaxX)//130
        {
            mainCam.transform.position =  new Vector3(MaxX,mainCam.transform.position.y,mainCam.transform.position.z);
        }
		//transform.LookAt( GameObject.FindGameObjectWithTag("Player").transform);
    }