code works well now