corrected the fields inside search function and added comments