Improved function definition and added function calling