removed some unneeded printlns
Use headOption instead of ifs