repaired printer function and proper casting