Fix tile calculation