Added corner handling