Updated logic and added features