improve findig free space logic