clear up code and use getResource() intead of filesystem path