fixed command line bug
added Factory pattern