Implemented better JS Interface

Simplified code, implemented better interface