Shortening code logic