Refactored the add tile functionality