Remove unneeded explicit cast
Use number of total pages to determine if there is a free page available