Fixed functionality of js