Removed useless vars and added conditional to guard