add safe check and formatting js

@indytechcook - I will merge this to dev. Just fyi..
 This doesn't have to be patched into prod as the bug today on prod is a backend api issue and was gone when shannon reverted the api. If we wanted to patch front-end as well, you can find the code in this branch.