Fixes division by 0 error and page type error