Implemented js promise handling