added try/catch clause and sending user credential through function call