Changed max_id calculation to using bcmath module