Code improvements; Implement phpjs functions