added doc and moved the instance variable creation inside