moving x,y,margin parameters to variables, adjusted top and left for image