Commented and finished functionality