code have been more complex, but not working yet