changed function names and used prototype approach