Improved window and check position code