Fixed undefined input
Made code prettier