Changed formatting and cast variables

Changed the formatting to be a bit more readable.  Also cast $character as string and $count as int.  Add validation for both parameters.