refactored javascript view function
separating concerns in view and adding var
tidying consolelogs
final tidy up for the day