changed coordinates calculations to ceil