Improve code, add more functionality