My assignment solution ^_^