Added proper logging and error preventions
Added example
fixed js file output